//
//  UserCenterPage.swift
//  Uber
//
//  Created by chen on 16/3/14.
//  Copyright © 2016年 chen. All rights reserved.
//

import UIKit

class UserCenterPage: FxBasePage,UITableViewDataSource,UITableViewDelegate {

    var owner:FxBasePage?
    @IBOutlet var tableView:UITableView!
    @IBOutlet var imageView:UIImageView!
    var datas: [UserInfo]!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        initDatas()
        self.tableView!.registerClass(UITableViewCell.self, forCellReuseIdentifier: "CellID")
        self.view.addSubview(tableView)
        self.tableView.reloadData()
    }
    
    @IBAction func doSetting() {
        let own = self.owner as! HomeCenterPage
        
        own.doShowSetting()
    }
    func initDatas(){
        var data:UserInfo!
        let dict:[String:String] = [
            "付款":"BaiDuWallet.png",
            "历史记录":"YinLian.png",
            "帮助":"AliPay.png",
            "优惠劵":"CreditCard.png",
            "我的消费":"CreditCard.png",
            "退出":"YinLian.png"
        ]
        datas = []
        for (key,value) in dict{
            data = UserInfo()
            data.name = key
            data.icon = value
            datas.append(data)
        }
    }
    
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return datas.count
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let identify:String = "CellID"
        let cell = tableView.dequeueReusableCellWithIdentifier(identify, forIndexPath: indexPath)
        let payInfo = datas[indexPath.row]
        cell.contentView.backgroundColor = UIColor.blackColor()
        cell.textLabel?.text = payInfo.name
        cell.textLabel?.textColor = UIColor.whiteColor()
        cell.textLabel?.backgroundColor = UIColor.blackColor()
        cell.imageView?.image = UIImage(named: payInfo.icon)
        cell.accessoryType = .None
        return cell
    }
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return 65.0
    }
    
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//        let page = YinLianPage()
//        self.navigationController?.pushViewController(page, animated: true)
//
//        let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
//        appDelegate.showHomePage()
        let own = self.owner as! HomeCenterPage
        own.doShowSetting()

        print(indexPath.row)
    }
    

}
